package com.ganlinux.pangoo.controller.restful.app;

import com.alibaba.fastjson.JSON;
import com.ganlinux.pangoo.controller.restful.base.BaseController;
import com.ganlinux.pangoo.dao.othermodel.AddressSearchModel;
import com.ganlinux.pangoo.entity.request.ReqAddressSearchList;
import com.ganlinux.pangoo.entity.request.ReqFootPrintSimpleInfoList;
import com.ganlinux.pangoo.entity.response.RspAddressSearchData;
import com.ganlinux.pangoo.entity.response.base.RspBase;
import com.ganlinux.pangoo.tools.AppUtil;
import com.jfinal.aop.Before;
import com.jfinal.kit.HttpKit;

/**
 * BlogController
 * 所有 sql 与业务逻辑写在 Model 或 Service 中，不要写在 Controller 中，养成好习惯，有利于大型项目的开发与维护
 */
@Before(AddressSearchInterceptor.class)
public class AddressSearchController extends BaseController {
	public void save() {
		super.save();
		RspBase rspLogin = new RspBase();

		String pin = null;
		String keywords = null;

		String jsonString= HttpKit.readData(getRequest());
		ReqAddressSearchList reqLogin = JSON.parseObject(jsonString, ReqAddressSearchList.class);
		reqLogin.setReqHeader(getHeaderFromRequest(getRequest()));
		pin = reqLogin.getReqHeader().getPin();
		keywords = reqLogin.getKeywords();
		AddressSearchModel addressSearchModel = new AddressSearchModel();

//			addressSearchModel.getAddressSearch();
//			RspAMapPlaceSearch rspAMapPlaceSearch = addressSearchModel.getAMapAddressSearch();
		RspAddressSearchData rspAddressSearchData = AppUtil.transRspAMapPlaceSearch2RspAddressSearchData(addressSearchModel.getAMapAddressSearch(keywords));
		rspLogin.setData(rspAddressSearchData);
		rspLogin.setStatus(0);
		rspLogin.setMessage("成功");

		renderText(JSON.toJSONString(rspLogin));
	}

}


